package cn.hchaojie.camp.day01;

import java.math.BigDecimal;

public class DemoTypeConvert {
	public static void main(String[] args) {
		System.out.println((double) 10 / 3);
		System.out.println(10 / (double) 3);
		
		int result = (int) (10 / 3.0);
		System.out.println(result);
		
		System.out.println((int) 3.5);
		System.out.println((int) Math.round(3.6));
		
		float f = 11 * 2.0F;
		System.out.println(f);
		
		float f1 = 11L + 2.0F;
		System.out.println(f1);
		
		long l = 123423434123L;
		int i = (int) l;
		System.out.println(i);
		
		l = 3L;
		i = (int) l;		
		System.out.println(i);
		
		// 浮点数不能用于精确计算
		double a = 1.0;
		double b = 0.9;
		System.out.println(a - b);	
		
		boolean equal = (1.0 - 0.9) == 0.1;
		System.out.println(equal);
		
		// 精确计算，用BigDecimal
		BigDecimal a1 = new BigDecimal("1.0");
		BigDecimal b1 = new BigDecimal("0.9");
		System.out.println(a1.subtract(b1));		//  
		
	}
}
